home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / mac / data / menu_dvd.swf / scripts / __Packages / CAlert.as next >
Text File  |  2007-11-07  |  5KB  |  155 lines

  1. class CAlert extends mx.core.UIObject
  2. {
  3.    var mAutoHide = true;
  4.    function CAlert()
  5.    {
  6.       super();
  7.       this.mOkCallback = null;
  8.       this.mYesCallback = null;
  9.       this.mNoCallback = null;
  10.       this.mCancelCallback = null;
  11.       this.mCssInitDone = false;
  12.       this.Init();
  13.    }
  14.    function SetCallback(inButtonId, inCallerObj, inFunctionName, inArgArray)
  15.    {
  16.       if(inButtonId.toLowerCase() == "ok")
  17.       {
  18.          this.mOkCallback = {callerObject:inCallerObj,functionName:inFunctionName,argArray:inArgArray};
  19.       }
  20.       else if(inButtonId.toLowerCase() == "yes")
  21.       {
  22.          this.mYesCallback = {callerObject:inCallerObj,functionName:inFunctionName,argArray:inArgArray};
  23.       }
  24.       else if(inButtonId.toLowerCase() == "no")
  25.       {
  26.          this.mNoCallback = {callerObject:inCallerObj,functionName:inFunctionName,argArray:inArgArray};
  27.       }
  28.       else if(inButtonId.toLowerCase() == "cancel")
  29.       {
  30.          this.mCancelCallback = {callerObject:inCallerObj,functionName:inFunctionName,argArray:inArgArray};
  31.       }
  32.    }
  33.    function Init()
  34.    {
  35.       this._x = (Stage.width - this.mc_dialog_bkg._width) / 2;
  36.       this._y = (Stage.height - this.mc_dialog_bkg._height) / 2;
  37.       var orgPoint = {x:0,y:0};
  38.       this.mc_grab_clip.globalToLocal(orgPoint);
  39.       this.mc_grab_clip._x = orgPoint.x;
  40.       this.mc_grab_clip._y = orgPoint.y;
  41.       this.mc_grab_clip._width = Stage.width;
  42.       this.mc_grab_clip._height = Stage.height;
  43.       this.mc_grab_clip.onPress = function()
  44.       {
  45.       };
  46.       this.mc_grab_clip.useHandCursor = false;
  47.       this.mc_grab_clip._alpha = 10;
  48.       this.txt_AlertTitle.html = true;
  49.       this.txt_AlertMessage.html = true;
  50.       this.txt_AlertTitle.wordWrap = true;
  51.       this.txt_AlertMessage.wordWrap = true;
  52.       this.txt_AlertTitle.embedFonts = _global.gUseEmbeddedFont;
  53.       this.txt_AlertMessage.embedFonts = _global.gUseEmbeddedFont;
  54.       this.Hide();
  55.    }
  56.    function InitCSS()
  57.    {
  58.       if(this.mCssInitDone == true)
  59.       {
  60.          return undefined;
  61.       }
  62.       this.mCssInitDone = true;
  63.       this.txt_AlertTitle.embedFonts = _global.gUseEmbeddedFont;
  64.       this.txt_AlertMessage.embedFonts = _global.gUseEmbeddedFont;
  65.       this.txt_AlertTitle.styleSheet = _global.gStyleManager.GetCSS();
  66.       this.txt_AlertMessage.styleSheet = _global.gStyleManager.GetCSS();
  67.    }
  68.    function ShowAlert(inTitle, inMessage, inFrameLabel, inBkgAlpha)
  69.    {
  70.       this.InitCSS();
  71.       var titoloDialog = inTitle;
  72.       if(titoloDialog.length == 0)
  73.       {
  74.          titoloDialog = CAlert.DEFAULT_TITLE;
  75.       }
  76.       this.txt_AlertTitle.htmlText = "<span class=\'alertTitle\'>" + titoloDialog + "</span>";
  77.       this.txt_AlertMessage.htmlText = "<span class=\'alertTesto\'>" + inMessage + "</span>";
  78.       this.mc_grab_clip._alpha = inBkgAlpha;
  79.       this._visible = true;
  80.       this.gotoAndStop(inFrameLabel.toLowerCase());
  81.    }
  82.    function ShowAlertByMsgId(inMsgId, inFrameLabel, inBkgAlpha)
  83.    {
  84.       if(!this.mMessage)
  85.       {
  86.          return undefined;
  87.       }
  88.       this.InitCSS();
  89.       var theMessage = this.mMessage.GetMessage(inMsgId);
  90.       if(!theMessage)
  91.       {
  92.          trace("ID MESSAGE NOT FOUND");
  93.          return undefined;
  94.       }
  95.       this.txt_AlertTitle.text = "<span class=\'alertTitle\'>" + theMessage.title + "</span>";
  96.       this.txt_AlertMessage.text = "<span class=\'alertTesto\'>" + theMessage.body + "</span>";
  97.       this.mc_grab_clip._alpha = inBkgAlpha;
  98.       this._visible = true;
  99.       this.gotoAndStop(inFrameLabel);
  100.    }
  101.    function Hide()
  102.    {
  103.       this._visible = false;
  104.    }
  105.    function YesBtnCallback()
  106.    {
  107.       if(this.mAutoHide == true)
  108.       {
  109.          this.Hide();
  110.       }
  111.       if(this.mYesCallback != null)
  112.       {
  113.          this.mYesCallback.callerObject[this.mYesCallback.functionName].apply(this.mYesCallback.callerObject,this.mYesCallback.argArray);
  114.          this.mYesCallback = null;
  115.       }
  116.    }
  117.    function NoBtnCallback()
  118.    {
  119.       if(this.mAutoHide == true)
  120.       {
  121.          this.Hide();
  122.       }
  123.       if(this.mNoCallback != null)
  124.       {
  125.          this.mNoCallback.callerObject[this.mNoCallback.functionName].apply(this.mNoCallback.callerObject,this.mNoCallback.argArray);
  126.          this.mNoCallback = null;
  127.       }
  128.    }
  129.    function CancelBtnCallback()
  130.    {
  131.       if(this.mAutoHide == true)
  132.       {
  133.          this.Hide();
  134.       }
  135.       if(this.mCancelCallback != null)
  136.       {
  137.          this.mCancelCallback.callerObject[this.mCancelCallback.functionName].apply(this.mCancelCallback.callerObject,this.mCancelCallback.argArray);
  138.          this.mCancelCallback = null;
  139.       }
  140.    }
  141.    function OkBtnCallback()
  142.    {
  143.       trace("OkBtnCallback");
  144.       if(this.mAutoHide == true)
  145.       {
  146.          this.Hide();
  147.       }
  148.       if(this.mOkCallback != null)
  149.       {
  150.          this.mOkCallback.callerObject[this.mOkCallback.functionName].apply(this.mOkCallback.callerObject,this.mOkCallback.argArray);
  151.          this.mOkCallback = null;
  152.       }
  153.    }
  154. }
  155.